<?
//var_dump($_REQUEST);
                
if ($haveUserList)
 if (($suser_list))
        {
                
          for($i=0;$i<sizeof($suser_list);$i++)
          {
          $user=$suser_list[$i];
          
           if ($suser_list[$i]=='all')
              $user=false;
           
           list($query, $udata[$i]) = ReportMgr::getQueryData($q, $DivT, $user, $dt1, $dt2);
           
          }

        }

?>
<table border=0 width='100%'>
 <tr>
 <td>
 <div id="placeholder" style="width:100%;height:300px;"></div>
 <script id="source" language="javascript" type="text/javascript">

   function showTooltip(x, y, contents) {

        $('<div id="tooltip" class="txt">' + contents + '</div>').css( {
            position: 'absolute',
            display: 'none',
            top: y + 5,
            left: x + 5,
            border: '1px solid #fdd',
            padding: '2px',
            'background-color': '#fee',
            opacity: 0.80
        }).appendTo("body").fadeIn(200);
    }

     var options = {
    grid: { hoverable: true, clickable: true },
    xaxis: {
            mode: "time",
            timeformat: "<?=$f2 ?>"
            }

     };

    var previousPoint = null;
    $("#placeholder").bind("plothover", function (event, pos, item) {
        $("#x").text(pos.x.toFixed(2));
        $("#y").text(pos.y.toFixed(2));

        if (true) {

            if (item) {

                if (previousPoint != item.datapoint) {
                    previousPoint = item.datapoint;

                    $("#tooltip").remove();



                    showTooltip(item.pageX, item.pageY, item.datapoint[1]);
                }
            }
            else {
                $("#tooltip").remove();
                previousPoint = null;
            }
        }
    });



$(function () {

   <?

   $i=0;
   $str='';

   if (isset($udata))
   foreach($udata as $uitem)
   {
   
   ?>
    var d<?=$i ?> = [];
    <?

       foreach($uitem as $item)
       {


       $dtm = $item->dtm*1000;
       ?>
            d<?=$i ?>.push(["<?=$dtm ?>", <?=$item->val ?>]);

       <?
       }
      $str.=' ,
      {
       label: "'.$suser_list[$i] .'",
       data: d'.$i.',
       lines: { show: true, fill: true, steps: true },
       points: { show: true }
      }
      ';
      $i++;
    }
    ?>

    $.plot($("#placeholder"),  [
    /*{
    label: "all",
    data: d1,
    lines: { show: true, fill: true, steps: true },
    points: { show: true },
    stack: 0,
    bars: { show: true, barWidth: 0.6 }
     }*/{} <?=$str ?>
    ], options
    );



    $('#det').multiSelect(
    {
    select_all_min: 3,
    no_selection: "Не выбрано",
    selected_text: " выбрано"  
    });



    
});
</script>
 </td>

 <? 
 /*
 if ($suser_list)
        {

		$ulist=$suser_list;

		usort($ulist, 'cmp_val');

        ?>
         <td width='130px' valign='top'>
         <div class='user_list'>
        <?

          for($i=0;$i<6;$i++)
          {
           $user = $ulist[$i];

           ?>
           <?=($i+1) ?>.<?=$user->user_name ?><br/>
           <?

          }
          ?>
          </div>

           </td>
        <?
        }    */
        ?>


</tr>
</table>